package com.lanou.dllo.findfood.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.lanou.dllo.findfood.R;

/**
 * Created by dllo on 15/11/4.
 */
public class ChangNameActivity extends Activity implements View.OnClickListener {
    private ImageView goCenter;
    private TextView saveName;
    private EditText personname;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.changename);

        initView();

        Intent intent = getIntent();
        String name = intent.getStringExtra("name");// 得到键值put对应的get
        personname.setText(name);


    }

    private void initView() {
        goCenter = (ImageView) findViewById(R.id.goCenter);
        goCenter.setOnClickListener(this);
        saveName = (TextView) findViewById(R.id.saveName);
        saveName.setOnClickListener(this);
        personname = (EditText) findViewById(R.id.personnameEt);


    }


    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.goCenter:
                finish();
            break;
            case R.id.saveName:

                Intent intent = new Intent();
                intent.putExtra("personName", personname.getText().toString());
                setResult(100,intent);
                finish();

            break;
            default:
                break;
        }

    }
}
